package com.zzy.collection.sortUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.google.common.collect.Maps;  
  
/** 
 *  
 * @author yinaibang 
 * 
 */  
public class TestMap {  
  
    public static void main(String[] args) throws Exception {  
  
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();  
        
        
        Map<String, Object> map1 = Maps.newHashMap();
        map1.put("id", 1);
        map1.put("name", "白云");

        Map<String, Object> map2 = Maps.newHashMap();
        map2.put("id", 2);
        map2.put("name", "李四");
        
        Map<String, Object> map3 = Maps.newHashMap();
        map3.put("id", 2);
        map3.put("name", "赵九");
        
        Map<String, Object> map4 = Maps.newHashMap();
        map4.put("id", 5);
        map4.put("name", "赵九");
        
        
        
        list.add(map1);
        list.add(map2);
        list.add(map3);
        list.add(map4);
        
  
        // 按ch倒序排序  
        boolean [] isAscArr = {false, true};  
        ListSortUtil.sort(list,  new String[] {"name", "id"}, isAscArr);  
        System.out.println("\n---------按name倒序-----------------");  
        TestMap.printfUserInfoList(list);  
  
    }  
  
    private static void printfUserInfoList(List<Map<String, Object>> list) {  
        for (Map<String, Object> map : list) {  
            System.out.println(map);  
        }  
    }  
}